import ControlLayer.AddressCtr;

import static org.junit.Assert.*;

import ModelLayer.Person;
import org.junit.Test;

public class testAddressBook {
    ControlLayer.AddressCtr actr = new AddressCtr();

    @Test
    public void testPersonCreation() {
        actr.createPerson("jj", "jj", "jj", "jj", "jj", "jj");
        // check if multiply(10,5) returns 50

        String description = "Person must be created";
        try{
            assertNotNull(description, actr.getPerson(1));
            System.out.println(description + " - passed");
        }catch(AssertionError e){
            System.out.println(description + " - failed");

            throw e;
        }
    }

    @Test
    public void testUpdatePerson() {
        actr.createPerson("jj", "jj", "jj", "jj", "jj", "jj");
        actr.updatePersonById(1, "ja", "fa", "da", "rr", "aa", "daa");
        Person p = actr.getPerson(1);
        String name = p.getName();
        //actr.getPerson(1).getName();

        String description = "Person edited correctly";
        try{
            assertEquals(name, "ja");
            System.out.println(description + " - passed");
        }catch(AssertionError e){
            System.out.println(description + " - failed");

            throw e;
        }
    }

    @Test
    public void deletePerson() {
        actr.createPerson("jj", "jj", "jj", "jj", "jj", "jj");
        actr.deletePersonById(1);

        String description = "Person deletion";
        try{
            assertNull(actr.getPerson(1));
            System.out.println(description + " - passed");
        }catch(AssertionError e){
            System.out.println(description + " - failed");

            throw e;
        }
    }

    @Test
    public void testListAllPersons() {
        actr.createPerson("jj", "jj", "jj", "jj", "jj", "jj");

        String description = "List all";
        try{
            assertNotNull("Not null", actr.listAllPersons());
            System.out.println(description + " - passed");
        }catch(AssertionError e){
            System.out.println(description + " - failed");

            throw e;
        }
    }

}